package com.knight.spring.framework.aop.adapter;

import com.knight.spring.framework.aop.intercept.KnightMethodInvocation;

import java.lang.reflect.Method;

public class KnightAfterThrowingAdviceInterceptor extends KnightAbstractAspectAdvice{

    private String throwingName;

    public KnightAfterThrowingAdviceInterceptor(Method aspectMethod, Object aspectTarget) {
        super(aspectMethod, aspectTarget);
    }

    @Override
    public Object invoke(KnightMethodInvocation invocation) throws Throwable {
        try {
            return invocation.proceed();
        }catch (Throwable e){
            invokeAdviceMethod(invocation,null,e);
            throw  e;
        }
    }

    public void setThrowName(String throwName){
        this.throwingName = throwName;
    }
}
